from __future__ import annotations

from datetime import date
from typing import Optional

from pydantic import Field

from app.schemas.common import APIModel, Timestamped


class CycleLogBase(APIModel):
  start_date: date
  end_date: Optional[date] = None
  symptoms: Optional[dict] = None
  notes: Optional[str] = None


class CycleLogCreate(CycleLogBase):
  pass


class CycleLogUpdate(APIModel):
  start_date: Optional[date] = None
  end_date: Optional[date] = None
  symptoms: Optional[dict] = None
  notes: Optional[str] = None


class CycleLogResponse(CycleLogBase, Timestamped):
  id: int
  symptoms: Optional[dict] = Field(default=None, alias="symptoms_json")
  relationship_id: Optional[int] = None


class CyclePrediction(APIModel):
  id: int
  phase: str
  phase_label: str | None = None
  start_date: date
  end_date: date
  confidence: float
  relationship_id: Optional[int] = None


class CycleDayLogBase(APIModel):
  date: date
  flow_level: str = 'none'
  symptoms: Optional[dict] = None
  mood: Optional[str] = None
  temperature: Optional[float] = None


class CycleDayLogCreate(CycleDayLogBase):
  pass


class CycleDayLogUpdate(APIModel):
  flow_level: Optional[str] = None
  symptoms: Optional[dict] = None
  mood: Optional[str] = None
  temperature: Optional[float] = None


class CycleDayLogResponse(CycleDayLogBase, Timestamped):
  id: int
  symptoms: Optional[dict] = Field(default=None, alias='symptoms_json')
  relationship_id: Optional[int] = None
